﻿@{
    ViewBag.Title = "角色列表";
    Layout = "~/Views/Shared/_LayoutList.cshtml"; 
}
@(       
 Html.DWZGridFor<RoleInfo>()
    .Title("角色列表")
    .Action(@Url.Action("RoleList"))
    .Columns(col =>
    {
        col.Bind(e => e.Id).IsKey();
        col.Bind(e => e.RoleCode).Width(80).AsQuery().Align(FlexiGridAlign.Left);
        col.Bind(e => e.RoleName).Width(80).AsQuery().Align(FlexiGridAlign.Left);
        col.Bind(e => e.Remark).Width("auto").Align(FlexiGridAlign.Left);
        col.Bind(e => e.IsSystem).Javascript("value == 'False'?'普通':'系统'").Width(50);
        col.Bind(e => e.SeqNo).Width(40);
        col.Bind(e => e.UpdateUser).Width(60);
        col.Bind(e => e.UpdateDate).Width(70).DateFormat("yyyy-MM-dd");
        col.Bind(e => e.Id, "操作", 240).Sortable(false)
            .Template(Url.EditLink("EditRole", "编辑角色")
            + Url.DeleteLink("DeleteRole", "${RoleName}")
            + Url.GridLink("setuser", "成员", "viewusers('${RoleCode}','${RoleName}')")
            + Url.GridLink("setuser", "授权", "authorization('${RoleCode}','${RoleName}')"));
    })
    .Buttons(btn =>
    {
        btn.Bind("Add", "新建角色", FlexiGridButtonType.Add).Action(@Url.Action("EditRole")).OnPress("OpenFormDailog");
    })
)
<script type="text/javascript">
    function viewusers(roleCode, roleName) {
        var url = '@Url.Action("RoleUserRelationList")?roleCode=' + roleCode;
        OpenModelWindow(url, { caption: roleName + " 下的成员", width: 500, height: 400 });
    }
    function authorization(roleCode, roleName) {
        var url = '@Url.Action("SetRolePrivilege")?roleCode=' + roleCode;
        OpenModelWindow(url, { caption: "对角色[" + roleName + "]授权", width: 300, height: 400, type: 2, onclose: function () {
            showLoadingMsg("操作成功！", { left: 300, top: 1 }, true, 3000);
        }
        });
    }
</script>
